package com.buanalintas.sandals.pos.entities;

import com.buanalintas.bynga.formatter.MoneyFormatter;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

@Entity
@Table(name = "pos_master_price_buy")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "PosMasterPriceBuy.findAll", query = "SELECT p FROM PosMasterPriceBuy p"),
    @NamedQuery(name = "PosMasterPriceBuy.findBySync", query = "SELECT p FROM PosMasterPriceBuy p WHERE p.sync = :sync"),
    @NamedQuery(name = "PosMasterPriceBuy.findByPriceBuyId", query = "SELECT p FROM PosMasterPriceBuy p WHERE p.priceBuyId = :priceBuyId"),
    @NamedQuery(name = "PosMasterPriceBuy.findByPriceBuyValue", query = "SELECT p FROM PosMasterPriceBuy p WHERE p.priceBuyValue = :priceBuyValue")})
public class PosMasterPriceBuy implements Serializable {
    @OneToMany(mappedBy = "itemPriceBuyId")
    private Collection<PosMasterItem> posMasterItemCollection;

    private static final long serialVersionUID = 1L;
    @Column(name = "sync")
    private String sync;
    @Id
    @Basic(optional = false)
    @Column(name = "price_buy_id")
    private Integer priceBuyId;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "price_buy_value")
    private BigDecimal priceBuyValue;

    public PosMasterPriceBuy() {
    }

    public Integer getPriceBuyId() {
        return priceBuyId;
    }

    public void setPriceBuyId(Integer priceBuyId) {
        this.priceBuyId = priceBuyId;
    }

    public BigDecimal getPriceBuyValue() {
        return priceBuyValue;
    }

    public void setPriceBuyValue(BigDecimal priceBuyValue) {
        this.priceBuyValue = priceBuyValue;
    }

    public String getSync() {
        return sync;
    }

    public void setSync(String sync) {
        this.sync = sync;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (priceBuyId != null ? priceBuyId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PosMasterPriceBuy)) {
            return false;
        }
        PosMasterPriceBuy other = (PosMasterPriceBuy) object;
        if ((this.priceBuyId == null && other.priceBuyId != null) || (this.priceBuyId != null && !this.priceBuyId.equals(other.priceBuyId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return MoneyFormatter.getInstance().format(priceBuyValue);
    }

    @XmlTransient
    public Collection<PosMasterItem> getPosMasterItemCollection() {
        return posMasterItemCollection;
    }

    public void setPosMasterItemCollection(Collection<PosMasterItem> posMasterItemCollection) {
        this.posMasterItemCollection = posMasterItemCollection;
    }
}
